'use strict';

const Controller = require('egg').Controller;

class blogController extends Controller {
    /* 问答及子页面 -------------------------------------------------------------- */
    async blog(){
        const { initInterestData } = require('../utils/index');
        const page = this.ctx.query.page || 1;
        const parentId = this.ctx.query.parentId||'';
        const categoryId = this.ctx.query.categoryId || parentId || '';

        const category = await this.ctx.service.mainCategory.mainCategory();
        const categoryResult = initInterestData(category);

        var memberList = await this.ctx.service.banner.bannerList('vip_area');
        var list = await this.ctx.service.blog.list(page,15,categoryId);

        var data = {
            memberList:memberList,
            category:categoryResult,
            list:list,
            categoryId:categoryId,
            parentId:parentId,
        };
        await this.ctx.render('page/blog/blog.html',{data:data});
    }


    async blog_content(){
        const id = this.ctx.params.id || '';
        var content = await this.ctx.service.blog.listContent(id);
        await this.ctx.render('page/blog/blog_content.html',{data:content});
    }

}

module.exports = blogController;






/**
 * Created by EDZ on 2018/10/19.
 */
